home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Games / Glypha II 1.21 / source / Code ƒ / A-Globals.p next >
Encoding:
Text File  |  1993-06-02  |  5.8 KB  |  247 lines  |  [TEXT/PJMM]

  1. unit Globals;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Palettes, Sound;
  7.  
  8.     const
  9.         stackSize = 32768;
  10.  
  11.         kSpaceKey = $31;
  12.         kLeftKey1 = $29;
  13.         kLeftKey2 = $00;
  14.         kRightKey1 = $27;
  15.         kRightKey2 = $01;
  16.  
  17.         sleep = 10;
  18.         suspendResumeBit = $0001;
  19.         resuming = 1;
  20.         WNETrapNum = $60;
  21.         unimplTrapNum = $9F;
  22.  
  23.         kRightFace = 0;
  24.         kLeftFace = 1;
  25.  
  26.         kEnemyModeRange = 30;
  27.         kEnemyModeMinumum = 30;
  28.         kInitEnemyModeRange = 50;
  29.         kInitEnemyModeMinumum = 50;
  30.         kEggDelayRange = 500;
  31.         kEggLevelPenalty = 5;
  32.         kSpaceBar = $20;
  33.  
  34.         noSound = 0;
  35.         lowPriority = 1;
  36.         highPriority = 2;
  37.  
  38.         liftAmount = -7;    {originally -8}
  39.         fallAmount = 1;
  40.         maxFall = 8;            {originally 10}
  41.         maxThrust = 16;
  42.         defaultNum = 5;
  43.         maxEnemies = 4;
  44.         newMortalPts = 10000;
  45.  
  46.         upperEyeHeight = 100;
  47.         lowerEyeHeight = 200;
  48.         handTop = 380;
  49.         handBottom = 470;
  50.         handLeft = 433;
  51.  
  52.         upperLevel = 0;
  53.         lowerLevel = 1;
  54.         upperEye = 2;
  55.         lowerEye = 3;
  56.  
  57.         fast = 3;
  58.         slow = 4;
  59.  
  60.         backPictID = 130;
  61.         objectPictID = 131;
  62.         maskPictID = 132;
  63.         helpPictID = 133;
  64.  
  65.         alertStrIDs = 128;
  66.         yesNoStrIDs = 129;
  67.  
  68.         alertID = 128;
  69.         controlDialID = 129;
  70.         hiNameDialID = 130;
  71.         aboutDialID = 131;
  72.         yesNoAlertID = 132;
  73.         configGameDialID = 133;
  74.  
  75.         mainWndoID = 128;
  76.  
  77.         mApple = 128;                {Menu list}
  78.         iAbout = 1;
  79.         mGame = 129;                    {Menu list}
  80.         iBegin = 1;
  81.         iPause = 2;
  82.         iEnd = 3;
  83.         iQuit = 5;
  84.         mOptions = 130;            {Menu list}
  85.         iConfigure_Game = 1;
  86.         iConfigure_Controls = 2;
  87.         iHelp = 4;
  88.         iClear_HiScores = 5;
  89.  
  90.     type
  91.         GameObject = record
  92.                 oldDest, dest, wholeRect: Rect;
  93.                 horiVel, vertVel: Integer;
  94.                 facing: Integer;
  95.                 mode, otherMode, tempInt: Integer;
  96.                 state, otherState: Boolean;
  97.             end;
  98.  
  99.         Bolt = record
  100.                 levelStriking: Integer;
  101.                 leftMode, rightMode: Integer;
  102.                 leftBolts, rightBolts: array[0..3, 0..3, 0..11] of Point;
  103.             end;
  104.  
  105.         BitMapPtr = ^BitMap;
  106.  
  107.     var
  108.         {Here follow all the major global variables                            }
  109.         {(yes, there are quite a few)                                                        }
  110.         {Here are then menu handles                                                            }
  111.  
  112.         theEvent: EventRecord;
  113.  
  114.         {Integers keep track of numbers, level, modes, etc...        }
  115.         rightOffset, downOffset: Integer;
  116.         numberOfStones, levelOn, mortals, oldDirection: Integer;
  117.         beastsKilled, beastsActive, totalToKill, levelStart, mortalsStart: Integer;
  118.         gameSpeed, startStone, growRate, numberOfEnemies: Integer;
  119.  
  120.         {Score is LongInt for the 12 yr old kids that top    36727    }
  121.         gameCycle, score, oldScore, nextMortal: LongInt;
  122.  
  123.         {Keep track of the name last entered for the high score    }
  124.         nameUsing: Str255;
  125.  
  126.         {Here follow the offscreen bitmap and window variables    }
  127.         mainWndo: WindowPtr;
  128.         mainPalette: PaletteHandle;
  129.         playRgn, obeliskRgn1, obeliskRgn2: RgnHandle;
  130.         smallOffArea, wholeArea: Rect;
  131.         offMaskMap: BitMap;
  132.         offMaskPort: GrafPtr;
  133.         offMaskBits: Ptr;
  134.         virginCPort, loadCPort, objectCPort: CGrafPort;
  135.         virginCPtr, loadCPtr, objectCPtr: CGrafPtr;
  136.         virginCBits, loadCBits, objectCBits: Ptr;
  137.         rgbBlack, rgbWhite, rgbLtBlue, rgbYellow, rgbRed: RGBColor;
  138.  
  139.         {Here are some of the object definition records                    }
  140.         theEye, theHand, thePlayer: GameObject;
  141.         lightning: Bolt;
  142.  
  143.         {Miscellaneous rects for the score box, platforms, etc..}
  144.         playRect, shortStoneSrc, longStoneSrc: Rect;
  145.  
  146.         {For the digitized sound                                                                }
  147.         chanPtr: sndchannelptr;
  148.         soundPriority: Integer;
  149.  
  150.         {Arrays hold hiscores made and read from .RSRC fork            }
  151.         hiScores: array[1..10] of LongInt;
  152.         hiStrings: array[1..10] of Str255;
  153.  
  154.         {These vars hold info on the enemies                                        }
  155.         theEnemies: array[0..9] of GameObject;
  156.         enemyLift: array[0..2] of Integer;
  157.  
  158.         {These vars hold locations of all artwork on offscreens    }
  159.         tombRects: array[-5..6] of Rect;
  160.         playerRects: array[0..1, 0..5] of Rect;
  161.  
  162.         enemyRects: array[0..2, 0..5, 0..1] of Rect;
  163.         boneRects: array[0..1, 6..7] of Rect;
  164.  
  165.         absoluteRects: array[0..1, 0..5] of Rect;
  166.         eyeRects: array[0..4] of Rect;
  167.  
  168.         handRects: array[0..1] of Rect;
  169.         ankRects: array[0..15] of Rect;
  170.  
  171.         eggRects, gameoverRects: Rect;
  172.         flameRect: array[0..1] of Rect;
  173.         running: array[-16..16, 0..1, 0..1] of Integer;
  174.         idleLanded: array[-16..16] of Integer;
  175.         gliding: array[-16..16, 0..1] of Integer;
  176.         impacted: array[-70..16] of Integer;
  177.  
  178. {The boolean vars often keep track of the game state        }
  179.  
  180.         playing, pausing, keyboardControl, soundOn, inBackground: Boolean;
  181.         deadAndGone, scoresChanged, inhibitSound, doneFlag: Boolean;
  182.         onward, keyStillDown, stonesSliding, hasWNE: Boolean;
  183.  
  184.     procedure DoErrorSound (soundNumber: Integer);
  185.     procedure GenericAlert (whatGives: Integer);
  186.  
  187. implementation
  188.  
  189. {=================================}
  190.  
  191.     procedure DoErrorSound;
  192.         var
  193.             dummyLong: LongInt;
  194.             tempVolume, i: Integer;
  195.     begin
  196.         GetSoundVol(tempVolume);
  197.         if (tempVolume <> 0) then
  198.             for i := 0 to soundNumber do
  199.                 begin
  200.                     FlashMenuBar(0);
  201.                     Delay(8, dummyLong);
  202.                     FlashMenuBar(0);
  203.                 end;
  204.     end;
  205.  
  206. {=================================}
  207.  
  208.     procedure GenericAlert;
  209.         var
  210.             dummyInt: Integer;
  211.             line1, line2: Str255;
  212.             alertHandle: AlertTHndl;
  213.             alertRect: Rect;
  214.     begin
  215.         InitCursor;
  216.         if (whatGives > 0) then
  217.             begin
  218.                 GetIndString(line1, alertStrIDs, whatGives);
  219.                 line2 := '';
  220.             end
  221.         else
  222.             begin
  223.                 GetIndString(line1, alertStrIDs, 1);
  224.                 NumToString(whatGives, line2);
  225.                 line2 := CONCAT('Error = ', line2);
  226.             end;
  227.  
  228.         ParamText(line1, line2, '', '');
  229.         alertHandle := AlertTHndl(Get1Resource('ALRT', alertID));
  230.         if (alertHandle <> nil) then
  231.             begin
  232.                 HNoPurge(Handle(alertHandle));
  233.                 alertRect := alertHandle^^.boundsRect;
  234.                 OffsetRect(alertRect, -alertRect.left, -alertRect.top);
  235.                 dummyInt := (screenBits.bounds.right - alertRect.right) div 2;
  236.                 OffsetRect(alertRect, dummyInt, 0);
  237.                 dummyInt := (screenBits.bounds.bottom - alertRect.bottom) div 3;
  238.                 OffsetRect(alertRect, 0, dummyInt);
  239.                 alertHandle^^.boundsRect := alertRect;
  240.                 HPurge(Handle(alertHandle));
  241.             end;
  242.         dummyInt := Alert(alertID, nil);
  243.     end;
  244.  
  245. {=================================}
  246.  
  247. end.